import java.util.Random;
import java.util.Scanner; //需要导入util包

public class Test {
    public static void main(String[] args) {
        Random a = new Random(); //默认随机种子是系统时间
        Scanner b = new Scanner(System.in);
        int guess = a.nextInt(100);
        System.out.println("游戏开始啦");
        while(true){
            System.out.println("请输入数字：");
            int num = b.nextInt();
            if(num < guess){
                System.out.println("低了");
            } else if (num > guess) {
                System.out.println("高了");
            }else{
                System.out.println("猜对了");
                break; //猜对了游戏结束
            }
        }
        b.close();
    }
    public static void main11(String[] args) {
        Scanner a = new Scanner(System.in);
        int num = a.nextInt();
        //1个整数4个字节32个比特位
        System.out.print("奇数位：");
        for (int i = 31; i >= 1; i -= 2) {
            System.out.print(num >> i & 1);//先右移 再&1，即可得到该位的值
        }
        System.out.print("偶数位");
        for (int i = 30; i >= 0; i -= 2) {
            System.out.print(num >> i & 1);
        }
    }
    public static void main10(String[] args) {
        Scanner a = new Scanner(System.in);
        int num = a.nextInt();
        int count = 0;
        while(num != 0){
            num = num & (num - 1);
            count++;
        }
        System.out.println(count);
    }
    public static void main9(String[] args) {
        for (int i = 0; i < 999999; i++) {
            //判断位数
            int tmp = i;
            int count = 0;
            while(tmp != 0){
                tmp = tmp / 10;
                count++;
            }
            //判断水仙花
            tmp = i;
            int sum = 0;
            while(tmp != 0){
                sum += Math.pow(tmp % 10, count);
                tmp = tmp / 10;
            }
            if(sum == i){
                System.out.println(i);
            }
        }
    }
    public static void main8(String[] args) {
        for (int i = 100; i < 999; i++) {
            int sum = 0;
            int tmp = i;
            while(tmp != 0){
                sum += Math.pow(tmp % 10, 3);
                tmp = tmp / 10;
            }
            if(sum == i)
                System.out.println(i + "为水仙花数");
        }
    }
    public static void main7(String[] args) {
        Scanner a = new Scanner(System.in);
        int x = a.nextInt();
        int y = a.nextInt();
        int min = x > y ? x : y;
        for (int i = min; i >= 1 ; i--) {
            if(x % i == 0 && y % i == 0){
                System.out.println(i);
                break;
            }
        }
    }
    public static void main6(String[] args) {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                int x = i * j;
                if(i == 3 && j == 2 || i == 4 && j == 2){
                    System.out.print(j + "*" + i + "=" + x + "  ");
                }else{
                    System.out.print(j + "*" + i + "=" + x + " ");

                }
            }
            System.out.println(" ");
        }
    }
    public static void main5(String[] args) {
        for (int i = 1000; i <= 2000; i++) {
            if(i % 400 == 0 || i % 100 != 0 && i % 4 == 0){
                System.out.println(i + "是闰年");
            }
        }
    }
    public static void main4(String[] args) {
        for (int j = 1; j <= 100; j++) {
            int i = 2;
            for (; i <= Math.sqrt(j); i++) {
                if(j % i == 0){
                    break;
                }
            }
            //注意：代码运行到这里有两种情况 1.break跳出循环 2.for循环正好走完
            if(i > Math.sqrt(j)){
                System.out.println(j + "是素数");
            }/*else{
                System.out.println(j + "不是素数");
            }*/
        }

    }
    public static void main3(String[] args) {
        Scanner a = new Scanner(System.in);
        System.out.println("请输入数字：");
        int num = a.nextInt();
        int i = 2;
        for (; i <= Math.sqrt(num); i++) {
            if(num % i == 0){
                break;
            }
        }
        //注意：代码运行到这里有两种情况 1.break跳出循环 2.for循环正好走完
        if(i > Math.sqrt(num)){
            System.out.println(num + "是素数");
        }else{
            System.out.println(num + "不是素数");
        }
    }
    public static void main2(String[] args) {
        Scanner a = new Scanner(System.in);
        System.out.println("请输入年龄：");
        int age = a.nextInt();
        if(age <= 18){
            System.out.println("少年");
        }else if(age >= 19 && age <= 28){
            System.out.println("青年");
        } else if (age >= 29 && age <= 55) {
            System.out.println("中年");
        } else if (age >= 56) {
            System.out.println("老年");
        }
    }
    public static void main1(String[] args) {

        Scanner a = new Scanner(System.in);
        int sum = 0;
        while (a.hasNextInt()){
            int tmp = a.nextInt();
            sum += tmp;
        }
        System.out.println(sum);

        /*System.out.println("请输入姓名：");
        String name = a.nextLine();
        System.out.println("请输入年龄：");
        int age = a.nextInt();
        System.out.println("请输入薪资：");
        float wage = a.nextFloat();
        a.close();
        System.out.println("姓名" + name + "\n" + "年龄" + age + "\n" + "薪资" + wage + "\n");*/
    }
}